﻿@using pageRes = FlashCards.WebApp.Resources.PageResources
@model FlashCards.WebApp.Models.AddExistingFlashcardSetToGroupModel
@{
    ViewBag.Title = "AddExistingFlashcardSetToGroup";
}
<h2>
    AddExistingFlashcardSetToGroup</h2>
@if (Model != null)
{
    if (Model.Sets != null && Model.Sets.FlashcardSets.Count > 0)
    {
    <table>
        <tr>
            <th>@pageRes.FlashcardSetName
            </th>
            <th>@pageRes.FlashcardSetTags
            </th>
            <th>@pageRes.AssignToGroup
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.Sets.FlashcardSets)
        {
            <tr>
                <td>@item.Name
                </td>
                <td>@item.Tags
                </td>
                <td>@item.GroupName
                </td>
                <td>
                    @if (string.IsNullOrEmpty(item.GroupName))
                    {
                        using (Html.BeginForm(new { groupId = Model.Group.GroupId, setId = item.Id }))
                        {
                        <input runat="server" value="Dodaj" type="submit" /> 
                        }
                    }
                    else
                    {
                        using (Html.BeginForm("RemoveSetFromGroup", "Groups", new { groupId = Model.Group.GroupId, setId = item.Id }))
                        {
                        <input runat="server" value="Usuń powiązanie" type="submit" /> 
                        }
                    }
                </td>
            </tr>
        }
    </table>
    }
    else
    {
    <p>
        @pageRes.AddFlashcardSetsFirst
    </p>
    }
}